<?php

namespace app\common;

enum TaskStatus: int
{
    case TASK_SUCCESS = 1;
    case TASK_FAILED = 2;
    case TASK_CREATED = 3;
    case TASK_CONVERTER = 4;
    case TASK_CREATED_FAILED = 5;
    case TASK_TRYING = 6;

    public function getStatus(): string
    {
        return match ($this) {
            self::TASK_SUCCESS        => '转换成功',
            self::TASK_FAILED         => '转换失败',
            self::TASK_CREATED        => '任务创建成功',
            self::TASK_CONVERTER      => '转换中...',
            self::TASK_CREATED_FAILED => '任务创建失败',
            self::TASK_TRYING         => '任务分配中',
        };
    }

    public static function values(): array
    {
        $notes = [];
        $array = array_column(self::cases(), 'value');
        foreach ($array as $value) {
            $notes[$value] = self::from($value)->getStatus();
        }
        return $notes;
    }
}